//
//  PauseScreen.m
//  FrogDrying
//
//  Created by Le Thanh Hai on 5/18/13.
//
//

#import "PauseScreen.h"
#import "cocos2d.h"
static PauseScreen *pauseScreen;

@implementation PauseScreen
+(id)shareScreen
{
    if (!pauseScreen) {
        pauseScreen =[[[NSBundle mainBundle] loadNibNamed:@"PauseScreen" owner:self options:nil] lastObject];
    }
    return pauseScreen;
}

- (void)show
{
    pauseScreen.alpha = 0;
    CGRect rect = self.frame;
    if (!IS_IPHONE_5) {
        rect.size.width = 480;
        self.frame = rect;
    }
    [[CCDirector sharedDirector] pause];

    [appDelegate.navController.view addSubview:pauseScreen];
    [UIView animateWithDuration:0.3 animations:^{
        pauseScreen.alpha = 1.0f;
    }];
}

-(IBAction)close:(id)sender
{
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 0.0f;
    } completion:^(BOOL finished) {
        [self retain];
        [self removeFromSuperview];
        [[CCDirector sharedDirector] resume];
    }];
}

-(IBAction)home:(id)sender
{
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 0.0f;
    } completion:^(BOOL finished) {
        [self retain];
        [self removeFromSuperview];
        [[CCDirector sharedDirector] resume];
        [appDelegate showStartScreen];
    }];
}

-(IBAction)retry:(id)sender
{
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 0.0f;
    } completion:^(BOOL finished) {
        [self retain];
        [self removeFromSuperview];
        [[CCDirector sharedDirector] resume];
    }];
}

-(void)dealloc
{
    CCLOG(@"%s", __func__);
    [super dealloc];
}

@end
